package com.marktim.pokerpoker.game;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.marktim.pokerpoker.R;
import com.marktim.pokerpoker.server.Client;
import com.marktim.pokerpoker.server.Client.ClientListener;

public class ClientGameActivity extends Activity {

	private EditText content;
	private Button send;
	private TextView received;

	private Client client;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.game_client_test);
		
		content = (EditText) findViewById(R.id.content);
		send = (Button) findViewById(R.id.send);
		received = (TextView) findViewById(R.id.received);
		
		client = new Client();
		client.setListener(new ClientListener() {
			
			@Override
			public void onMessage(String message) {
				received.setText(received.getText() + message + "\n");
			}
		});

		send.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				client.sendToServer(content.getText().toString());
			}
		});
	}
}
